package cn.edu.hzvtc.mapper;

import cn.edu.hzvtc.model.entity.UserEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapper {

    @Insert("INSERT INTO users VALUES (NULL, #{username}, #{realname}, #{studentId}, #{pwdSalt}, #{pwd}, #{pwdErrorCount}, #{pwdValidDate}, #{userType}, #{gradeId}, #{classId})")
    void addUser(UserEntity userEntity);

    @Select("select id, username, realname, student_id, pwd_salt, pwd, pwd_valid_date, pwd_error_count, user_type, grade_id, class_id from users where username = #{username}")
    UserEntity findUserByUsername(@Param("username") String username);

}
